// pages/paySuccess/paySuccess.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      oid: options.oid
    })
  },

  //开门
  openDoor: function(e){
    var that = this;
    var curTime = e.timeStamp;
    var lastTime = this.data.lastTime;
    this.setData({
      lastTime: curTime
    })
    if (lastTime > 0) {
      if (curTime - lastTime < 500) {
        return false;//禁止连续点击
      }
    }
    //机器二维码链接https://vendorapi.lzljtdpx.com/gzjShopId?machineid=46&shopId=78
    wx.scanCode({
      onlyFromCamera: true,
      success: (res) => {
        var rest = res.result;
        if (rest.indexOf("gzjShopId?machineid") < 0) {
          util.showStatus("请扫描机器二维码");
          return;
        }
        var arr = res.result.split("?");
        var str1 = arr[1];
        var atrr1 = str1.split("&")[0];
        var machine_id = atrr1.split("=")[1];
        // var shopId = str1.split("&")[1].split("=")[1];
        wx.redirectTo({
          url: '../openDoor/openDoor?machine_id=' + machine_id + '&oid=' + that.data.oid,
        })
      }
    })
  },

})